const { ccclass, property } = cc._decorator;

import supScripts from "./supScripts"
//组件脚本管理
@ccclass
export default class supMount extends cc.Component {
    start() {
        supScripts.setMount(this.node.uuid, this);
        this.extendStart();
    }
    //组件脚本启动扩展
    protected extendStart() {
    }

    //获取逻辑脚本引用
    public getModule(uuid: string|null): any {
        return supScripts.getModule(uuid ? uuid : this.node.uuid);
    }

    //获取挂载脚本引用
    public getMount(uuid: string): any {
        return supScripts.getMount(uuid ? uuid : this.node.uuid);
    }

    //启动逻辑脚本模块
    protected startScript(name: string, object): any {
        let mod = this.getModule(name);
        if (!mod) {
            mod = new object();
        }
        mod.changeStart();
        return mod;
    }

    //关闭逻辑脚本模块
    protected closeCript(name: string | null): any {
        let mod = this.getModule(name);
        mod.changeClose();
        return mod;
    }

    //派发事件
    public dispatchs(data: any) {

    }
}
